// 比较版本号 
/**
 * @param {string} version1
 * @param {string} version2
 * @return {number}
 */
var compareVersion = function (version1, version2) {
  let arr1 = version1.split('.')
  let arr2 = version2.split('.')

  let i = 0, j = 0
  while (i < arr1.length && j < arr2.length) {
    if (Number(arr1[i]) < Number(arr2[j])) {
      return -1
    } else if (Number(arr1[i]) > Number(arr2[j])) {
      return 1
    }
    i++
    j++
  }
  if (i < arr1.length) {
    for (let k = i; k < arr1.length; k++) {
      if (Number(arr1[k]) !== 0) return 1
    }
  } else {
    for (let k = j; k < arr2.length; k++) {
      if (Number(arr2[k]) !== 0) return -1
    }
  }

  return 0
};


console.log(compareVersion('1.2', '1.10'));
